'''
Copyright(C),2021-2031, Zhenxin Tech. Co., Ltd.

FilePath: myserver.py
Author: zhangys
Date: 1969-12-31 16:00:00
LastEditTime: 2021-12-14 19:54:29
LastEditors: zhangys
Description: 使用自定义消息和服务
'''


from tutorial_interfaces.srv import AddThreeInts
import rclpy
from rclpy import service
from rclpy.node import Node

class Service(Node):
    def __init__(self):
        super().__init__('zys_service')
        self.srv=self.create_service(AddThreeInts,'zys_add',self.addCallBack) #此处的服务名称必须和客户一致。
    
    def addCallBack(self,request,response):
        response.sum=request.a+request.b+request.c
        self.get_logger().info('输入的值为\n a:%d b:%d  c:%d'%(request.a,request.b,request.c))
        return response

def main(args=None):
    rclpy.init(args=args)
    zys_service=Service()
    rclpy.spin(zys_service)
    rclpy.shutdown()

if __name__ == '__main__':
    main()
